package com.plusfoursix.game;

public class Monster extends GameObject {

	boolean active = false;
	int direction;
	
	
	public void init() {
		sprite.setX(-100);
		sprite.setY(-100);
	}
	
	public void logic() {
		sprite.setY(sprite.getY() + 1);
		
		// if out of screen then deactivate the enemy
		if (sprite.getY() > Globals.SCREEN_HEIGHT) {
			active = false;
		}
		
		sprite.setX(sprite.getX() + direction);
		
		if (sprite.getX() > Globals.SCREEN_HEIGHT - sprite.getWidth()) {
			direction = -direction;
		}
		else if (sprite.getX() < 0) {
			direction = -direction;
		}
		
	}

	@Override
	public int getGraphic() {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean b) {
		active = b;
		
		if (active) {
			int pos = Math.abs(Globals.random.nextInt() % Globals.SCREEN_WIDTH);
			sprite.setX(pos);
			
			sprite.setY(0 - sprite.getHeight());
			
			direction = Globals.random.nextInt() % 2;
		}
		
	}

}
